package com.waitingresult.controller;

import com.waitingresult.entity.Entity1;
import com.waitingresult.entity.TestEntity1;
import com.waitingresult.entity.TestEntity2;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-10-25  23:00
 * @Description: TODO
 * @Version: 1.0
 */
@RestController("测试接口")
public class TestController {

    @RequestMapping(value = "test",name = "测试方法",method = RequestMethod.GET)
    public Object test(TestEntity1 test){
        TestEntity1 entity1 = new TestEntity1();
        entity1.setName("张三");
        List<Entity1> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Entity1 entity = new Entity1();
            entity.setAddress("张三"+i);
            entity.setPrice(BigDecimal.valueOf(i));
            list.add(entity);
        }
        entity1.setList(list);
        TestEntity2 testEntity2 = new TestEntity2();
        BeanUtils.copyProperties(entity1,testEntity2);
        return testEntity2;
    }

}
